<template>
  <div class='consume first-box'>
    <Filters @filterTime="search"></Filters>
    <Scroll :hasmore="hasmore" :pullup="pullup" setHeight="-33">
      <List :listData="listData"></List>
    </Scroll>
  </div>
</template>
<script>
import Filters from '../../../common/filters.vue'
import Scroll from '../../../common/scroller'
import List from './list'
export default {
  components: {Filters,Scroll,List},
  name: "",
  data() {
    return {
      hasmore:false,
      listData:[
        // {
        //   name:"美容洗车",
        //   money:"500",
        //   way:"会员卡余额",
        //   time:"2018-5-12"
        // }
      ],
      payWays:["微信","支付宝","会员卡余额","银联","现金"],
      pageInfo:{
        page:1,
        search:"",
        startTime:"",
        endTime:"",
      }
    };
  },
  methods: {
    
    // 下拉刷新方法回调
    pullup(func){
      if(this.hasmore){
        this.pageInfo.page++
         _g.orderList([this.getList,func])
         return
      }
      // func()
    },

    search(params){
      this.pageInfo.page=1
      if(params.search){
        this.pageInfo.search=params.search
      }
      if(params.time.length>0){
        this.pageInfo.startTime=params.time[0]
        this.pageInfo.endTime=params.time[1]
      }
      this.listData=[]
      this.getList()
    },

    getList(){
      var params={
        currPageNo:this.pageInfo.page,
        // typeId:this.selectedIndex
      }
      if(this.pageInfo.search){
        params.search=this.pageInfo.search
      }
      if(this.pageInfo.startTime&&this.pageInfo.endTime){
        params.startTime=this.pageInfo.startTime
        params.endTime=this.pageInfo.endTime
      }
      _g.apiPost("vipCenter/ConsumerDetails.do",params).then(res=>{
        this.hasmore=res.data.hasNextPage
        var goal=[]
        res.data.list.forEach(ele => {
            goal.push({
              name:ele.name||"暂无",
              money:ele.payMoney,
              way:ele.payTypeName,
              time:ele.time,
            })
        });
        this.$set(this,"listData",this.listData.concat(goal))
      })
    }
  },
  created() {
    this.getList()
  }
};
</script>
<style lang="scss" scoped>
.consume {

}
</style>